package Views;

import java.util.ArrayList;
import Adapters.GridItemAdapter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.TextView;
import main.pak.R;

public class GradeFragment extends Fragment {
	public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
	public static final GradeFragment newInstance(String message) {
		GradeFragment f = new GradeFragment();
		Bundle bdl = new Bundle(1);
		bdl.putString(EXTRA_MESSAGE, message);
		f.setArguments(bdl);
		return f;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		String message = getArguments().getString(EXTRA_MESSAGE);
		View v = inflater.inflate( R.layout.grade, container, false);

		ArrayList image_details = getListData();
		TextView vtxtView = (TextView)v.findViewById(R.id.textView1);
		// final ListView lv1 = (ListView) findViewById(R.id.custom_list);
		final GridView lv1 = (GridView) v.findViewById(R.id.gridview);
		lv1.setAdapter(new GridItemAdapter(this.getActivity(), image_details));
		vtxtView.setText(this.getArguments().getString(EXTRA_MESSAGE));
		//ImageView vImgView = (ImageView) v.findViewById(R.id.imgItem);
		//vImgView.setBackgroundDrawable(getResources().getDrawable(R.drawable.prek));
		return v;
	}

	private ArrayList getListData() {
		ArrayList results = new ArrayList();
		GridGradeItem newsData = new GridGradeItem();
		newsData.setMDrawable(getResources().getDrawable(R.drawable.prek));
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		results.add(newsData);
		return results;
	}

}